/* 回到顶部 */
$.fn.goTop = function (dom) {

  var _this = this;
  _this.html('<img src="images/index/pximg/icon-s-item8.png" alt="">');

  _this.css({
    cursor: "pointer",
    display: "none",
    position: "fixed",
    "z-index": "9999",
  });
  _this.find("img").css({
    width: "100%"
  });
  //var clientHeight = document.documentElement.clientHeight; //获取可视区域的高度
  var height_block = 20; //将高度分成N段
  var thisFn = {
    onScroll: function () {
      //获取滚动条的滚动高度
      var osTop = 0;
      if (dom) {
        osTop = $(dom).scrollTop();
      } else {
        osTop = document.documentElement.scrollTop || document.body.scrollTop;
      }
      var is_show = _this.css("display");
      if (osTop > 0) {
        if (is_show == 'none') {
          _this.fadeIn();
        }
      }
      if (osTop <= 0) {
        _this.fadeOut();
      }
    },
    goTopFn: function () {
      //获取滚动条的滚动高度
      var osTop = 0;
      //用于设置速度差，产生缓动的效果
      var speed = 0;

      if (dom) {
        osTop = $(dom).scrollTop();
        speed = Math.floor(-osTop / height_block);
        $(dom).scrollTop(osTop + speed);
      } else {
        osTop = document.documentElement.scrollTop || document.body.scrollTop;
        speed = Math.floor(-osTop / height_block);
        document.documentElement.scrollTop = document.body.scrollTop = osTop + speed;
      }

      var is_show = _this.css("display");
      if (osTop > 0) {
        if (is_show == 'none') {
          _this.fadeIn();
        }
        setTimeout(function () {
          thisFn.goTopFn();
        }, 20);
      }
    }
  };

  if (dom) {
    $(dom).on('scroll', function () {
      thisFn.onScroll();
    });
  } else {
    window.onscroll = function () {
      thisFn.onScroll();
    }
  }

  //回到顶部按钮点击事件
  _this.off().on("click", function () {
    thisFn.goTopFn();
  });
}

   $(function() {
      $("img").lazyload({effect: "fadeIn"});
  });
  $(function() {
   var _height = $(".body-cnt").height();
   var _top_h = $(".top-box").height();
   $(".item-box").height(_height - _top_h);
   $(".list4").goTop();
 });